﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace RaProWorld
{
    class Ltan_enemy
    {
        public Texture2D sprite;
        float speed;
        float fallSpeed;
        public Rectangle hitbox;
        public Vector2 position;
        public bool isRubbing;
        public bool isFalling;
        public int staerke;

        public Ltan_enemy(Texture2D newSprite,float newSpeed) 
        {
            sprite = newSprite;
            speed = newSpeed;
            fallSpeed = 0.0f;
            position = new Vector2((float)1024.0f + (sprite.Width / 2), (float)675.0f - (sprite.Height / 2));
            hitbox = new Rectangle((int)position.X - (sprite.Width / 2), (int)position.Y - (sprite.Height / 2), sprite.Width, sprite.Height);
            isRubbing = false;
            staerke = 3;
        }

        public void update(GameTime gameTime, bool isScrolling, float playerSpeed,Vector2 playerPos)
        {
            if (!isRubbing)
            {
                position.X = position.X - speed;
                if (isScrolling)
                {
                    position.X -= playerSpeed;
                }
                hitbox.X = (int)position.X - (sprite.Width / 2);
            }
            if(isRubbing&&!isFalling) 
            {
                position = playerPos;
            }
            if (isRubbing && isFalling) 
            {
                fallSpeed += 0.3f;
                position.Y += fallSpeed;
            }
        }

        public void draw(SpriteBatch spriteBatch,GameTime gameTime)
        {
            spriteBatch.Draw(sprite,
                position,
                null,
                Color.White,
                0.0f,
                new Vector2(sprite.Width / 2, sprite.Height / 2),
                1.0f,
                SpriteEffects.None,
                0);
        }
    }
}
